import Vuex,{Store} from 'vuex'

import Vue from 'vue'

Vue.use(Vuex)

let store = new Store({
    state:{
        list:[],
        subList:[],
        detailData:{}
    },
    mutations:{
        setList(state,actions){
            state.list = [...actions.list]
        },
        getSubList(state,actions){
            
            let index = state.list.findIndex(item=>item.id === actions.id)

            state.subList = [...state.list[index].sub]
        },
        getDetail(state,actions){
            let index = state.subList.findIndex(item=>item.id === actions.id)
            
            state.detailData = {...state.subList[index]}

        }
    }
})

export default store